﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace HigLabo.Net.Twitter
{
    public partial class TwitterClient
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callback"></param>
        public void GetSavedSearchesList(Action<SavedSearchCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.SavedSearches.GetSavedSearchesUrl
                , json => callback(new SavedSearchCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void GetSavedSearchesById(Int64 id, Action<SavedSearch> callback)
        {
            String url = String.Format(TwitterApiUrl.Version1_1.SavedSearches.GetSavedSearchesByIdUrl, id);
            this.GetResultText(url, json => callback(new SavedSearch(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        /// <param name="callback"></param>
        public void CreateSavedSearches(String query, Action<SavedSearch> callback)
        {
            CreateSavedSearchesCommand command = new CreateSavedSearchesCommand();
            command.Query = query;
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.SavedSearches.CreateSavedSearchesUrl, command
                , json => callback(new SavedSearch(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void CreateSavedSearches(CreateSavedSearchesCommand command, Action<SavedSearch> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.SavedSearches.CreateSavedSearchesUrl, command
                , json => callback(new SavedSearch(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void DestroySavedSearches(Int64 id, Action<SavedSearch> callback)
        {
            String url = String.Format(TwitterApiUrl.Version1_1.SavedSearches.DestroySavedSearchesIdUrl, id);
            this.GetResultText(HttpMethodName.Post, url
                , json => callback(new SavedSearch(json)));
        }
    }
}
